package com.enation.app.web.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.enation.app.web.core.model.Address;
import com.enation.app.web.core.service.IAddressManager;
import com.enation.framework.database.IDaoSupport;

/**
 * 
 * @function 地址管理实现
 * @author 闯哥
 * @time 2016年12月25日 上午10:49:40
 */
@Service
public class AddressManager implements IAddressManager {

	@Autowired
	private IDaoSupport daoSupport;

	@Override
	public List<Address> getProvince() {

		String sql = "select * from es_china where pid=0";
		List<Address> addresses = this.daoSupport.queryForList(sql,
				Address.class);
		return addresses;
	}

	@Override
	public List<Address> getParentByPid(Integer pid) {

		String sql = "select * from es_china where pid=?";
		List<Address> addresses = this.daoSupport.queryForList(sql,
				Address.class, pid);
		return addresses;
	}

	@Override
	public int checkexist(Integer id) {

		String sql = "select count(*) from es_china where id=?";
		Integer count = this.daoSupport.queryForInt(sql, id);
		if (count > 0) {
			return 1;
		}
		return 0;
	}

}
